home *** CD-ROM | disk | FTP | other *** search
- unit ListViewEx2;
-
- interface
-
- uses
- Windows, Messages, Classes, Controls, ComCtrls, CommCtrl;
-
- type
- //This is a variation on the wm_Notify message record
- //that is used for certain listview notification messages
- TWMListViewNotify = packed record
- Msg: Cardinal;
- IDCtrl: Longint;
- NMLV: PNMListView;
- Result: Longint;
- end;
-
- TItemCheckEvent = procedure (Sender: TCustomListView;
- Item: TListItem; Checked: Boolean) of object;
-
- TListViewEx2 = class(TListView)
- private
- FOnCheck: TItemCheckEvent;
- protected
- procedure CNNotify(var Msg: TWMListViewNotify);
- message cn_Notify;
- published
- property OnCheck: TItemCheckEvent read FOnCheck write FOnCheck;
- end;
-
- procedure Register;
-
- implementation
-
- procedure Register;
- begin
- RegisterComponents('Clinic', [TListViewEx2]);
- end;
-
- { TListViewEx2 }
-
- procedure TListViewEx2.CNNotify(var Msg: TWMListViewNotify);
- const
- OldChecked: Boolean = False;
- OldItem: Integer = -1;
- begin
- with Msg.NMLV^ do
- case hdr.code of
- LVN_ITEMCHANGING:
- begin
- Olditem := iItem;
- OldChecked := Items[OldItem].Checked;
- end;
- LVN_ITEMCHANGED:
- if (iItem = OldItem) and (Items[iItem].Checked <> OldChecked) and
- Assigned(FOnCheck) then
- FOnCheck(Self, Items[iItem], Items[iItem].Checked)
- end;
- inherited;
- end;
-
- end.
-